package cn.fl.project.service.impl;

import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.capital.condition.CapPayInfoQueryCondition;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.condition.PrjPaySchSplmtQC;
import cn.fl.project.dto.PrjPaySchSplmtDTO;
import cn.fl.project.service.IPrjPaySchSplmtApiService;
import cn.fl.project.service.IPrjPaySchSplmtService;
import cn.fl.project.transform.PrjPaySchSplmtVOTransform;
import cn.fl.project.vo.PrjPaySchSplmtVO;
import cmm.mid.core.framework.page.Pager;


/**
 * @Description: 风险保证金补充信息表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class PrjPaySchSplmtServiceImpl implements IPrjPaySchSplmtService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(PrjPaySchSplmtServiceImpl.class);
	
	@Autowired
	private IPrjPaySchSplmtApiService prjPaySchSplmtApiService;
	
	@Override
	public PrjPaySchSplmtVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "获取对象主键不能为空!");
		}
		//TODO 业务逻辑
		PrjPaySchSplmtDTO dto = this.prjPaySchSplmtApiService.selectById(id,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
		return PrjPaySchSplmtVOTransform.toVO(dto);
	}

	@Override
	public Long add(PrjPaySchSplmtVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增对象不存在!");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"新增对象不存在!");
		};
		return this.prjPaySchSplmtApiService.add(PrjPaySchSplmtVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "删除对象主键不能为空!");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"删除对象主键不能为空!");
		};
		return this.prjPaySchSplmtApiService.removePrjPaySchSplmtDTOById(id);
	}
	
	@Override
	public boolean modify(PrjPaySchSplmtVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "修改对象不能为空!");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"修改对象不能为空!");
		};
		return this.prjPaySchSplmtApiService.modifyPrjPaySchSplmtDTO(PrjPaySchSplmtVOTransform.toDTO(entity));
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
		if(CollectionUtils.isEmpty(ids)){
			BaseLogUtils.info(logger, "removeByIds", "删除主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"删除对象主键不能为空!");
		};
		return false;
    }

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page){
			page = new Pager();
		}
		//return this.prjPaySchSplmtApiService.searchPrjPaySchSplmtListPage(page);
		//TODO 业务逻辑
		return null;
	}

	/**
     * 根据条件查询所有
     * @param qc
     * @return
     */
	@Override
	public List<PrjPaySchSplmtVO> searchList(PrjPaySchSplmtQC qc) throws BaseException{
		if(null == qc){
			BaseLogUtils.info(logger, "selectList", "项目产品ID参数不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());//当前系统代码
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());//当前机构代码
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());//当前用户ID
		return PrjPaySchSplmtVOTransform.toVOList(prjPaySchSplmtApiService.searchList(qc));
	}

}
